package com.aspose.cells;

class ztz {
   private zol a;
   private ListObject b;

   ztz(zol var1, ListObject var2) {
      this.b = var2;
      this.a = var1;
   }

   void a(zcfx var1) throws Exception {
      var1.b(true);
      var1.b("table");
      var1.a("xmlns", zase.c);
      this.d(var1);
      if (this.b.q() && this.b.getShowHeaderRow()) {
         zuf.a(var1, this.b.r(), false);
      }

      if (this.b.r() != null && this.b.getAutoFilter().b != null) {
         zuf.a(var1, this.b.getAutoFilter().b);
      }

      this.c(var1);
      this.b(var1);
      var1.b();
      var1.d();
      var1.e();
   }

   private void b(zcfx var1) throws Exception {
      var1.b("tableStyleInfo");
      if (this.b.getTableStyleName() != null && !"None".equals(this.b.getTableStyleName())) {
         var1.a("name", this.b.getTableStyleName());
      }

      String var2 = this.b.getShowTableStyleFirstColumn() ? "1" : "0";
      var1.a("showFirstColumn", var2);
      var2 = this.b.getShowTableStyleLastColumn() ? "1" : "0";
      var1.a("showLastColumn", var2);
      var2 = this.b.getShowTableStyleRowStripes() ? "1" : "0";
      var1.a("showRowStripes", var2);
      var2 = this.b.getShowTableStyleColumnStripes() ? "1" : "0";
      var1.a("showColumnStripes", var2);
      var1.b();
   }

   private void c(zcfx var1) throws Exception {
      var1.b("tableColumns");
      int var2 = this.b.getListColumns().getCount();
      var1.a("count", zase.y(var2));

      for(int var3 = 0; var3 < var2; ++var3) {
         ListColumn var4 = this.b.getListColumns().get(var3);
         this.a(var1, var4);
      }

      var1.b();
   }

   private void a(zcfx var1, ListColumn var2) throws Exception {
      var1.b("tableColumn");
      int var3 = var2.o == -1 ? var2.c() + 1 : var2.o;
      var1.a("id", zase.y(var3));
      if (var2.j() != null) {
         var1.a("uniqueName", var2.j());
      }

      var1.a("name", var2.getName());
      String var4 = this.a(var2, 1);
      if (var4 != null) {
         var1.a("dataDxfId", var4);
      }

      if (var2.n() != -1) {
         var1.a("queryTableFieldId", zase.y(var2.n()));
      }

      if (var2.getTotalsCalculation() != 0) {
         var1.a("totalsRowFunction", zase.as(var2.getTotalsCalculation()));
      }

      if (var2.k() != null) {
         var1.a("totalsRowLabel", var2.k());
      }

      var4 = this.a(var2, 0);
      if (var4 != null) {
         var1.a("headerRowDxfId", var4);
      }

      var4 = this.a(var2, 2);
      if (var4 != null) {
         var1.a("totalsRowDxfId", var4);
      }

      if (var2.d != null) {
         var1.b("calculatedColumnFormula");
         if (var2.g()) {
            var1.a("array", "1");
         }

         String var5 = var2.h();
         if (var5.startsWith("=")) {
            var5 = var5.substring(1);
         }

         var1.a(var5);
         var1.b();
      }

      if (var2.f() != null) {
         var1.b("totalsRowFormula");
         if (var2.g()) {
            var1.a("array", "1");
         }

         var1.a(var2.f());
         var1.b();
      }

      if (var2.a != null) {
         var1.b("xmlColumnPr");
         var1.a("mapId", zase.y(var2.a.a));
         var1.a("xpath", var2.a.b);
         var1.a("xmlDataType", var2.a.c);
         var1.b();
      }

      var1.b();
   }

   private String a() {
      CellArea var1 = new CellArea();
      var1.StartRow = this.b.getStartRow();
      var1.StartColumn = this.b.getStartColumn();
      var1.EndRow = this.b.getEndRow();
      if (this.b.getEndRow() - this.b.getStartRow() == 0) {
         ++var1.EndRow;
      }

      var1.EndColumn = this.b.getEndColumn();
      return zase.a(var1);
   }

   private void d(zcfx var1) throws Exception {
      var1.a("id", zase.y(this.b.a()));
      String var2 = this.b.f();
      if (var2 != null) {
         var1.a("name", var2);
      }

      var2 = this.b.getDisplayName();
      if (var2 != null) {
         var1.a("displayName", var2);
      }

      var1.a("ref", this.a());
      if (this.b.getDataSourceType() != 0) {
         var1.a("tableType", zase.at(this.b.getDataSourceType()));
      }

      var2 = this.b.s();
      if (var2 != null) {
         var1.a("comment", var2);
      }

      if (this.b.i()) {
         var1.a("insertRow", "1");
      }

      int var3 = this.b.y() == -1 ? 1 : this.b.y();
      if (var3 != 1) {
         var1.a("headerRowCount", zase.y(var3));
      }

      if (!this.b.j()) {
         var1.a("totalsRowShown", "0");
      } else {
         int var4 = this.b.A() > 1 ? this.b.A() : 1;
         var1.a("totalsRowCount", zase.y(var4));
      }

      if (this.b.n()) {
         var1.a("published", "1");
      }

      var2 = this.a(0);
      if (var2 != null) {
         var1.a("headerRowDxfId", var2);
      }

      var2 = this.a(1);
      if (var2 != null) {
         var1.a("dataDxfId", var2);
      }

      var2 = this.a(2);
      if (var2 != null) {
         var1.a("totalsRowDxfId", var2);
      }

      var2 = this.a(3);
      if (var2 != null) {
         var1.a("tableBorderDxfId", var2);
      }

      var2 = this.a(4);
      if (var2 != null) {
         var1.a("headerRowBorderDxfId", var2);
      }

      var2 = this.a(5);
      if (var2 != null) {
         var1.a("totalsRowBorderDxfId", var2);
      }

      if (this.b.o() != -1) {
         var1.a("connectionId", zase.y(this.b.o()));
      }

   }

   private String a(int var1) {
      if (this.b.h != null && var1 >= 0 && var1 <= 5) {
         return this.b.h[var1] != -1 ? zase.y(this.b.h[var1]) : null;
      } else {
         return null;
      }
   }

   private String a(ListColumn var1, int var2) {
      if (var1.k != null && var2 >= 0 && var2 <= 2) {
         return var1.k[var2] != -1 ? zase.y(var1.k[var2]) : null;
      } else {
         return null;
      }
   }
}
